package com.deer.wms.ware.task.model.Wave;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.deer.wms.ware.task.constant.WareTaskConstant;
import com.deer.wms.ware.task.model.SO.SoDetail;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author wei
 * <br>
 * 波次明细
 */
@Getter
@Setter
@NoArgsConstructor
@Table(name = "wave_detail")
public class WaveDetail {
    /**
     * 主键
     */
    @Id
    @TableId(type = IdType.AUTO)
    @Column(name = "wave_detail_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer waveDetailId;

    /**
     * 波次ID
     */
    private Integer waveMasterId;

    /**
     * 波次编码
     */
    private String waveCode;

    /**
     * 波次明细编码
     */
    private String waveDetailCode;

    /**
     * 状态 新建 已分配  已合并  已拣货  已出库
     */
    private Integer state;

    /**
     * 仓库ID
     */
    @Column(name = "ware_id")
    private Integer wareId;

    /**
     * 仓库名称
     */
    @Column(name = "ware_name")
    private String wareName;

    /**
     * 库区编码
     */
    @Column(name = "area_code")
    private String areaCode;

    /**
     * 库区名
     */
    @Column(name = "area_name")
    private String areaName;

    /**
     * 物料编码
     */
    @Column(name = "item_code")
    private String itemCode;

    /**
     * 物料名称
     */
    @Column(name = "item_name")
    private String itemName;


    /**
     * 包装详情ID
     */
    @Column(name = "pack_detail_id")
    private Integer packDetailId;

    /**
     * 包装描述
     */
    @Column(name = "pack_describe")
    private String packDescribe;

    /**
     * 计划数量
     */
    @Column(name = "quantity")
    private Double quantity;

    /**
     * 分配数量
     */
    @Column(name = "allotted_quantity")
    private Double allottedQuantity;

    /**
     * 预分配数量
     */
    private Double preAllottedQuantity;

    /**
     * 分配时间
     */
    private LocalDateTime allottedTime;

    /**
     * 拣货数量
     */
    @Column(name = "pick_quantity")
    private Double pickQuantity;

    /**
     * 仓管员id
     */
    private Integer pickUserId;

    /**
     * 仓管员名
     */
    private String pickUserName;

    /**
     * SO明细ID
     */
    private Integer soDetailId;

    /**
     * SO ID
     */
    private Integer soMasterId;

    /**
     * 红篮字 0-返还件  1-普通件
     */
    private Boolean rob;

    /**
     * 先发配件数量
     * */
    private Double xfQuantity;

    @TableField(exist = false)
    private String feedCategory; //erp发料属性 关联item_info 表feedCategory字段

    public WaveDetail(SoDetail soDetail) {
        this.soDetailId = soDetail.getSoDetailId();
        this.itemCode = soDetail.getItemCode();
        this.itemName = soDetail.getItemName();
        this.packDetailId = soDetail.getPackDetailId();
        this.packDescribe = soDetail.getPackDescribe();
        this.state = WareTaskConstant.WAVE_STATE_PROCESSING;

        this.quantity = 0.0;
        this.allottedQuantity = 0.0;
        this.pickQuantity = 0.0;
    }
}